/**
 * 
 */

// Display the menu
function showCarList( brandSelect, modelSelect, firstEntry )
{	
	var brandSelectList = document.getElementById( brandSelect );

	if ( brandSelectList ) 
	{
		var modelSelectList = document.getElementById( modelSelect );
		
		// Clear the list
		while ( modelSelectList.childNodes.length >= 1 )
	    {
			modelSelectList.removeChild( modelSelectList.firstChild );       
	    }
		
		// Get the new selected index
		// -1 to handle the first entry ("Choisissez", etc.)
		var selectedIndex = brandSelectList.selectedIndex;
		
		if ( selectedIndex == 0 )
		{
			modelSelectList.disabled = true;
		}
		else
		{
			modelSelectList.disabled = false;
		}
		
		--selectedIndex;
		
		/*var newOption = document.createElement("option");
		newOption.innerHTML = "<option value='0'>Choisissez</option>";
		modelSelectList.appendChild( newOption );*/
		
		modelSelectList.options[ modelSelectList.options.length ] = new Option( firstEntry, 0 );
		
		for ( var i = 0; i < modelIds[ selectedIndex ].length; ++i )
		{
			/*var newOption = document.createElement("option");
			newOption.innerHTML = "<option value='"+ modelIds[ selectedIndex ][ i ] + "'>" + modelNames[ selectedIndex ][ i ] + "</option>";
			modelSelectList.appendChild( newOption );*/
			
			modelSelectList.options[ modelSelectList.options.length ] =
				new Option( modelNames[ selectedIndex ][ i ], modelIds[ selectedIndex ][ i ] );
		}
	}
}

function selectOption( modelSelect, selectedValue )
{
	var modelSelectList = document.getElementById( modelSelect );
	if ( modelSelectList ) 
	{
		for ( var i = 0; i < modelSelectList.options.length; ++i )
		{
			if ( modelSelectList.options[ i ] == selectedValue )
			{
				modelSelectList.options[ i ].selected = true;
			}
		}
	}
}